package org.dromara.germbank.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.constant.SystemConstants;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.germbank.domain.BusApplicationResource;
import org.dromara.germbank.domain.BusPartnerClinic;
import org.dromara.germbank.domain.bo.BusApplicationResourceBo;

import org.dromara.germbank.domain.vo.BusApplicationResourceVo;

import org.dromara.germbank.mapper.BusApplicationResourceMapper;
import org.dromara.germbank.service.BusApplicationResourceService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 资源合作神申请 实施类
 *
 * @author congxing
 */
@Slf4j
@RequiredArgsConstructor
@Service
public class BusApplicationResourceServiceImpl implements BusApplicationResourceService {

    private final BusApplicationResourceMapper busApplicationResourceMapper;

    /**
     * 查询合作伙伴管理
     */
    @Override
    public TableDataInfo<BusApplicationResourceVo> queryPageList(BusApplicationResourceBo bo, PageQuery pageQuery) {

        Page<BusApplicationResourceVo> page = busApplicationResourceMapper.queryPageList(pageQuery.build(),this.buildQueryWrapper(bo));
        return TableDataInfo.build(page);
    }

    @Override
    public boolean checkResourceNameUnique(BusApplicationResourceBo resource) {
        return false;
    }

    @Override
    public int insertAd(BusApplicationResourceBo resource) {
        return 0;
    }

    @Override
    public void updateResourceData(BusApplicationResourceBo resource) {

    }

    @Override
    public void deleteResourceDataByIds(List<Long> resource) {

    }

    // 分页查询条件
    private Wrapper<BusApplicationResource> buildQueryWrapper(BusApplicationResourceBo bo) {
        return Wrappers.<BusApplicationResource>lambdaQuery()
            // 逻辑删除字段（固定条件）
            .eq(BusApplicationResource::getDelFlag, SystemConstants.NORMAL)

            // 诊所名称（模糊）
            .like(StringUtils.isNotBlank(bo.getClinicName()),
                BusApplicationResource::getClinicName, bo.getClinicName())

            // 排序
            .orderByAsc(BusApplicationResource::getId);
    }
}
